import axios from 'axios';
import config from "@/util/config.js";

const API_URL = config.mdUrl+'/md/tool';

const toolAPI = {
    // 添加供应商
    getToolsByName(param, callback) {
        axios.get(`${API_URL}/get?toolName=${param.toolName}`)
            .then(res => callback(res.data))
            .catch(error => console.error('Error adding supporter: ', error));
    },
    getWorkTools(param, callback) {
        axios.get(`${API_URL}/work/get?workId=${param.idWork}`)
            .then(res => callback(res.data))
            .catch(error => console.error('Error adding supporter: ', error));
    },
    //插入
    addTools(param, callback) {
        axios.request({
            url: `${API_URL}/add?workId=`+param.idWork,
            method: 'post',
            data: JSON.stringify(param.tools),
            headers: {
                "Content-Type": "application/json;charset=UTF-8"
            }
        }).then(res => callback(res.data))
    },
};
export default toolAPI;